package com.xxx.plugin.util;

import java.io.*;

/**
 * Description
 * ...
 * DATE 2017/12/9.
 *
 * @author Mr. Chun.
 */
public class FiltUtil {

    private static String path = "./src/main/resources/";
    private static String fileName = "application-dev.yml";

    /**
     * 创建application文件
     */
    public static void touchApplication() {
        fileName = path + fileName;
        File file = new File(fileName);
        try {
            // 文件不存在，则创建
            if (!file.exists()) {
                file.createNewFile();
                System.out.println("created new file: " + fileName);
            }
            // 写内容
            FileWriter fw = new FileWriter(file, true);
            BufferedWriter bw = new BufferedWriter(fw);
            bw.write("server:\n" +
                    "  application:\n" +
                    "    name: qbs-auth\n" +
                    "  port: 8090");
            bw.flush();
            bw.close();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
